//
//  NSError+ZBError.m
//  ZBDay
//
//  Created by xzb on 2018/2/7.
//  Copyright © 2018年 xzb. All rights reserved.
//

#import "NSError+ZBError.h"

static NSString *kZBErrorDomain = @"xzb";

@implementation NSError (ZBError)

+ (NSError *)ZB_errorWithCode:(NSInteger)code errorMessage:(NSString*)errorMessage
{
    NSMutableDictionary* userInfo = [[NSMutableDictionary alloc] initWithCapacity:2];
    userInfo[@"error_code"] = [@(code) description];
    if ([errorMessage isKindOfClass:[NSString class]]) {
        userInfo[@"error_msg"] = errorMessage;
    }
    return [NSError errorWithDomain:kZBErrorDomain code:code userInfo:userInfo];
}

+ (NSError *)ZB_errorWithCode:(NSInteger)code userInfo:(NSDictionary *)userInfo
{
    return [NSError errorWithDomain:kZBErrorDomain
                               code:code
                           userInfo:userInfo];
}

@end
